From: Niklas Laxström Date: Fri, 5 May 2006 12:21:12 +0000 (+0000) Subject: * (bug 5805) message nbytes can now use {{plural:}} X-Git-Tag: 1.31.0-rc.0~57236 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=8b403ede36eaaed47f64b0a80aabb000150801f2;p=lhc%2Fweb%2Fwiklou.git * (bug 5805) message nbytes can now use {{plural:}} * Cleaned up Special:Imagelist a bit --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 54c3ae94ae..3df3aa451a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -212,6 +212,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN Special:Wantedcategories and Special:Mostlinkedcategories. * (bug 3309) Allow comments when undeleting pages * Clean up Special:Undelete a bit +* (bug 5805) message nbytes can now use {{plural:}} +* Clean up Special:Imagelist a bit == Compatibility == diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 59a8191817..5d9627ace6 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -554,7 +554,7 @@ function wfMsgWikiHtml( $key ) { * replaceafter: parameters are substituted after parsing or escaping */ function wfMsgExt( $key, $options ) { - global $wgOut; + global $wgOut, $wgMsgParserOptions, $wgParser; $args = func_get_args(); array_shift( $args ); @@ -578,7 +578,11 @@ function wfMsgExt( $key, $options ) { if( preg_match( "~^

(.*)\n?

$~", $string, $m ) ) { $string = $m[1]; } - } elseif ( in_array('escape', $options) ) { + } elseif ( in_array('parsemag', $options) ) { + $string = $wgParser->transformMsg($string, $wgMsgParserOptions); + } + + if ( in_array('escape', $options) ) { $string = htmlspecialchars ( $string ); } @@ -1623,7 +1627,7 @@ function in_string( $needle, $str ) { function wfSpecialList( $page, $details ) { global $wgContLang; - $details = $details ? $wgContLang->getDirMark() . " ($details)" : ""; + $details = $details ? ' ' . $wgContLang->getDirMark() . "($details)" : ""; return $page . $details; } diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 561cfb15c3..7e18464d2a 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -115,7 +115,8 @@ class ImageGallery if( $this->mShowBytes ) { if( $img->exists() ) { - $nb = wfMsgHtml( 'nbytes', $wgLang->formatNum( $img->getSize() ) ); + $nb = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), + $wgLang->formatNum( $img->getSize() ) ); } else { $nb = wfMsgHtml( 'filemissing' ); } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 98feeb417d..9f1a4807ff 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -755,7 +755,8 @@ class ImageHistoryList { $usertalk = $this->skin->makeLinkObj( Title::makeTitle( NS_USER_TALK, $usertext), $wgContLang->getNsText( NS_TALK ) ); $userdata = $userlink . ' (' . $usertalk . ')'; } - $nbytes = wfMsg( 'nbytes', $size ); + $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), + $wgLang->formatNum( $size ) ); $widthheight = wfMsg( 'widthheight', $width, $height ); $style = $this->skin->getInternalLinkAttributes( $url, $datetime ); diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php index 6438e9c716..5ef203f22a 100644 --- a/includes/SpecialImagelist.php +++ b/includes/SpecialImagelist.php @@ -18,10 +18,6 @@ function wfSpecialImagelist() { $sql = "SELECT img_size,img_name,img_user,img_user_text," . "img_description,img_timestamp FROM $image"; - $byname = wfMsg( "byname" ); - $bydate = wfMsg( "bydate" ); - $bysize = wfMsg( "bysize" ); - if ( !$wgMiserMode && !empty( $wpIlMatch ) ) { $nt = Title::newFromUrl( $wpIlMatch ); if($nt ) { @@ -31,82 +27,65 @@ function wfSpecialImagelist() { $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'"; } } + if ( "bysize" == $sort ) { $sql .= " ORDER BY img_size DESC"; - $st = $bysize; } else if ( "byname" == $sort ) { $sql .= " ORDER BY img_name"; - $st = $byname; } else { $sort = "bydate"; $sql .= " ORDER BY img_timestamp DESC"; - $st = $bydate; } + list( $limit, $offset ) = wfCheckLimits( 50 ); - if ( 0 == $limit ) { - $lt = wfMsg( 'imagelistall' ); - } else { - $lt = $wgLang->formatNum( "${limit}" ); - $sql .= " LIMIT {$limit}"; - } - $wgOut->addHTML( "

" . wfMsg( "imglegend" ) . "

\n" ); + $lt = $wgLang->formatNum( "${limit}" ); + $sql .= " LIMIT {$limit}"; - $text = wfMsg( "imagelisttext", - "{$lt}", "{$st}" ); - $wgOut->addHTML( "

{$text}\n

" ); + $wgOut->addWikiText( wfMsg( 'imglegend' ) ); + $wgOut->addWikiText( wfMsg( 'imagelisttext', $lt, wfMsg( $sort ) ) ); $sk = $wgUser->getSkin(); - $sub = wfMsg( "ilsubmit" ); $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" ); - $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" ); + $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" ); if ( !$wgMiserMode ) { $wgOut->addHTML( "
" . - " " . - "
" ); - } - $nums = array( 50, 100, 250, 500 ); - $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' ); - - $fill = ""; - $first = true; - foreach ( $nums as $num ) { - if ( ! $first ) { $fill .= " | "; } - $first = false; - - $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), - "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); + wfElement( 'input', + array( + 'type' => 'text', + 'size' => '20', + 'name' => 'wpIlMatch', + 'value' => $wpIlMatch, )) . + wfElement( 'input', + array( + 'type' => 'submit', + 'name' => 'wpIlSubmit', + 'value' => wfMsg( 'ilsubmit'), )) . + '' ); } - $text = wfMsg( "showlast", $fill, $byname ); - $wgOut->addHTML( "

{$text}
\n" ); - $fill = ""; - $first = true; - foreach ( $nums as $num ) { - if ( ! $first ) { $fill .= " | "; } - $first = false; - - $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), - "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); - } - $text = wfMsg( "showlast", $fill, $bysize ); - $wgOut->addHTML( "{$text}
\n" ); - - $fill = ""; - $first = true; - foreach ( $nums as $num ) { - if ( ! $first ) { $fill .= " | "; } - $first = false; + $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' ); - $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), - "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); + foreach ( array( 'byname', 'bysize', 'bydate') as $sorttype ) { + $urls = null; + foreach ( array( 50, 100, 250, 500 ) as $num ) { + $urls[] = $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), + "sort={$sorttype}&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); + } + $sortlinks[] = wfMsgExt( + 'showlast', + array( 'parseinline', 'replaceafter' ), + implode($urls, ' | '), + wfMsgExt( $sorttype, array('escape') ) + ); } - $text = wfMsg( "showlast", $fill, $bydate ); - $wgOut->addHTML( "{$text}

\n

" ); + $wgOut->addHTML( implode( $sortlinks, "
\n") . "\n\n


" ); + // lines + $wgOut->addHTML( '

' ); $res = $dbr->query( $sql, "wfSpecialImagelist" ); + while ( $s = $dbr->fetchObject( $res ) ) { $name = $s->img_name; $ut = $s->img_user_text; @@ -119,18 +98,21 @@ function wfSpecialImagelist() { $ilink = "" . strtr(htmlspecialchars( $name ), '_', ' ') . ""; - $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) ); - $l = "(" . - $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ), - wfMsg( "imgdesc" ) ) . - ") {$ilink} . . {$nb} . . {$ul} . . " . - $wgLang->timeanddate( $s->img_timestamp, true ); + $nb = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), + $wgLang->formatNum( $s->img_size ) ); + + $desc = $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ), + wfMsg( 'imgdesc' ) ); - $l .= $sk->commentBlock( $s->img_description ); - $wgOut->addHTML( "{$l}
\n" ); + $date = $wgLang->timeanddate( $s->img_timestamp, true ); + $comment = $sk->commentBlock( $s->img_description ); + + $l = "({$desc}) {$ilink} . . {$nb} . . {$ul} . . {$date} {$comment}
\n"; + $wgOut->addHTML( $l ); } - $wgOut->addHTML( "

" ); + $dbr->freeResult( $res ); + $wgOut->addHTML( '

' ); } ?> diff --git a/includes/SpecialMIMEsearch.php b/includes/SpecialMIMEsearch.php index 99c8ed3847..6789b6101e 100644 --- a/includes/SpecialMIMEsearch.php +++ b/includes/SpecialMIMEsearch.php @@ -70,12 +70,13 @@ class MIMEsearchPage extends QueryPage { $plink = $skin->makeLink( $nt->getPrefixedText(), $text ); $download = $skin->makeMediaLink( $nt->getText(), 'fuck me!', wfMsgHtml( 'download' ) ); - $bytes = wfMsg( 'nbytes', $wgLang->formatNum( $result->img_size ) ); + $bytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), + $wgLang->formatNum( $result->img_size ) ); $dimensions = wfMsg( 'widthheight', $result->img_width, $result->img_height ); $user = $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); $time = $wgLang->timeanddate( $result->img_timestamp ); - return "($download) $plink .. $dimensions .. $bytes .. $user .. $time"; + return "($download) $plink . . $dimensions . . $bytes . . $user . . $time"; } } diff --git a/includes/SpecialNewimages.php b/includes/SpecialNewimages.php index 58d434b70a..1215f2af35 100644 --- a/includes/SpecialNewimages.php +++ b/includes/SpecialNewimages.php @@ -148,7 +148,7 @@ function wfSpecialNewimages( $par, $specialPage ) { $bydate = wfMsg( 'bydate' ); $lt = $wgLang->formatNum( min( $shownImages, $limit ) ); if ($shownav) { - $text = wfMsg( 'imagelisttext', "{$lt}", "{$bydate}" ); + $text = wfMsg( 'imagelisttext', $lt, $bydate ); $wgOut->addHTML( "

{$text}\n

" ); } diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index 40e22f18b3..c67a24bf5b 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -76,7 +76,8 @@ class NewPagesPage extends QueryPage { $u = $result->user; $ut = $result->user_text; - $length = wfMsgHtml( 'nbytes', htmlspecialchars( $wgLang->formatNum( $result->length ) ) ); + $length = wfMsgExt( 'nbytes', array('parsemag', 'escape'), + $wgLang->formatNum( $result->length ) ); $d = $wgLang->timeanddate( $result->timestamp, true ); # Since there is no diff link, we need to give users a way to diff --git a/includes/SpecialSearch.php b/includes/SpecialSearch.php index f9a4c9b36c..1591b93235 100644 --- a/includes/SpecialSearch.php +++ b/includes/SpecialSearch.php @@ -316,7 +316,7 @@ class SpecialSearch { function showHit( $result, $terms ) { $fname = 'SpecialSearch::showHit'; wfProfileIn( $fname ); - global $wgUser, $wgContLang; + global $wgUser, $wgContLang, $wgLang; $t = $result->getTitle(); if( is_null( $t ) ) { @@ -333,7 +333,8 @@ class SpecialSearch { $link = $sk->makeKnownLinkObj( $t ); $revision = Revision::newFromTitle( $t ); $text = $revision->getText(); - $size = wfMsg( 'nbytes', strlen( $text ) ); + $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), + $wgLang->formatNum( strlen( $text ) ) ); $lines = explode( "\n", $text ); diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index 5d3dc3aaf2..6867b80eb7 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -54,7 +54,7 @@ class ShortPagesPage extends QueryPage { function formatResult( $skin, $result ) { global $wgLang, $wgContLang; - $nb = htmlspecialchars( wfMsg( 'nbytes', $wgLang->formatNum( $result->value ) ) ); + $nb = wfMsgExt( 'nbytes', array('parsemag', 'escape'), $wgLang->formatNum( $result->value ) ); $title = Title::makeTitle( $result->namespace, $result->title ); $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); $histlink = $skin->makeKnownLinkObj( $title, wfMsgHtml('hist'), 'action=history' ); diff --git a/languages/Messages.php b/languages/Messages.php index 7eb24ddbd7..a67041a4db 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -236,7 +236,7 @@ See $1.', 'versionrequired' => 'Version $1 of MediaWiki required', 'versionrequiredtext' => 'Version $1 of MediaWiki is required to use this page. See [[Special:Version]]', -'nbytes' => '$1 bytes', +'nbytes' => '$1 {{PLURAL:$1|byte|bytes}}', 'ncategories' => '$1 categories', 'nrevisions' => '$1 revisions', 'widthheight' => '$1x$2', @@ -847,11 +847,11 @@ created and by whom, and anything else you may know about it. If this is an imag # Image list # 'imagelist' => 'File list', -'imagelisttext' => "Below is a list of $1 files sorted $2.", +'imagelisttext' => 'Below is a list of $1 files sorted $2.', 'imagelistforuser' => "This shows only images uploaded by $1.", 'getimagelist' => 'fetching file list', 'ilsubmit' => 'Search', -'showlast' => "Show last $1 files sorted $2.", +'showlast' => 'Show last $1 files sorted $2.', 'byname' => 'by name', 'bydate' => 'by date', 'bysize' => 'by size',